//#region demo
import * as THREE from "three";
import { OrbitControls } from "three/addons/controls/OrbitControls.js";

//#region common
// 场景
const scene = new THREE.Scene();
// 相机
const camera = new THREE.PerspectiveCamera(
    45,
    window.innerWidth / window.innerHeight,
    1,
    500
);
camera.position.set(10, 20, 30);
camera.lookAt(0, 0, 0);
// 渲染器
const renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
// 辅助坐标轴
const axesHelper = new THREE.AxesHelper(20);
scene.add(axesHelper);
// 轨道控制
new OrbitControls(camera, renderer.domElement);
//#endregion common

//#region box
// 立方体
const geometry = new THREE.BoxGeometry(5, 5, 5);
const material = new THREE.MeshBasicMaterial({ color: 0x00ff00 });
const cube = new THREE.Mesh(geometry, material);
scene.add(cube);
//#endregion box

//#region rotation
// 旋转物体
cube.rotation.x = Math.PI / 4;
//#endregion rotation

// 执行渲染
function animate() {
    requestAnimationFrame(animate);
    renderer.render(scene, camera);
}

animate();
//#endregion demo
